package day06;
import java.util.Arrays;
public class Exercise {
    public static void main(String[] args) {
        say();
        sayHi("zhangsan");
        sayHello("zhangsan",31);
        plus(5,6);
        getNum();
       /* int [] arr1 = testArray(10,10);
        for(int i = 0;i<arr1.length;i++){
            System.out.print(arr1[i]+"  ");
        }*/
        /*int[] array = new int[10];
        int max = array[0];
        for(int i = 1;i<array.length;i++){
            array[i] = (int)(Math.random()*101);
            System.out.print(array[i]+"\t");
            if(array[i]>max){
                max = array[i];
            }
        }
        System.out.println();
        array = Arrays.copyOf(array,array.length+1);
        array[array.length-1] = max;
        for(int i = 0;i<array.length;i++){
            System.out.print(array[i]+"\t");
        }*/

          int [] arr ={63,87,99,54,21,5};
            int max = getMaxOfArray(arr);
        System.out.println(max);
        int [] as = new int[10];
        for(int i = 0;i<as.length;i++){
           as[i] = (int)(Math.random()*100);
            System.out.print(as[i]+"\t");
        }
        int m = getMaxOfArray(as);
        System.out.println(m);

    }
    public static void say(){
        System.out.println("hello");
    }
    public static void sayHi(String name){
        System.out.println("我叫"+name);
    }
    public static void sayHello(String name,int age){
        if(age>30){
            return;
        }
        System.out.println("我叫"+name+"，今年"+age+"岁。");
    }
    public static int getNum(){
        int a = (int)(Math.random()*100);
        if(a<50){
            System.out.println(a);
        }else {
            System.out.println(a+"+"+a);
        }

        return a;
    }
    public static int plus(int num1,int num2){
        int plus = num1+num2;
        System.out.println(plus);
        return plus;
    }
   /* public static int [] testArray(int len,int quantity){
        int [] arr = new int[len];
        for (int i = 0;i<arr.length;i++){
            arr[i] = (int)(Math.random()*quantity);
        }
        return arr;
    }*/
    public static int getMaxOfArray(int[]arr){
        int max = arr[0];
        for(int i = 1;i<arr.length;i++){
            if(arr[i]>max){
                max = arr[i];
            }
        }
        return max;
    }

}
